package com.ruoyi.merchant.service.impl;


import com.ruoyi.common.core.enums.CacheConstant;
import com.ruoyi.merchant.mapper.DictMapper;
import com.ruoyi.merchant.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;


/**
 * @ClassName CodeItemsServiceImpl
 * @Description 正常字典服务实现
 * @Author chenxin.ju
 * @Date 2020-03-21 16:03
 * @ProjectName juservicecloud
 * @Version 1.0
 **/
@Slf4j
@Service
public class DictServiceImpl  implements DictService {


    @Autowired
    private DictMapper dictMapper;

    /**
     * 通过查询指定table的 text code 获取字典值text
     * dictTableCache采用redis缓存有效期10分钟
     * @param table
     * @param text
     * @param code
     * @param key
     * @return
     */
    @Override
//    @Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE)
    public String queryTableDictTextByKey(String table,String text,String code, String key) {
        log.info("无缓存dictTable的时候调用这里！");
        return dictMapper.queryTableDictTextByKey(table,text,code,key);
    }


    /**
     * 通过查询指定code 获取字典值text
     * @param code
     * @param key
     * @return
     */

    @Override
//    @Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code+':'+#key")
    public String queryDictTextByKey(String code, String key) {
        log.info("无缓存dictText的时候调用这里！");
        return dictMapper.queryDictTextByKey(code, key);
    }
}
